﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace simplewebcms.Core.DomainObjects
{
    public class CMSPage
    {
        /// <summary>
        /// The name of this page.  It is used to
        /// key it into the site via url, and must be
        /// unique for the entire site.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// When the page was created.
        /// </summary>
        public DateTime CreatedOn { get; set; }

        /// <summary>
        /// When the page was last changed.
        /// </summary>
        public DateTime LastChangedOn { get; set; }

        /// <summary>
        /// The name of which layout to use for the page.
        /// </summary>
        public string LayoutName { get; set; }

        /// <summary>
        /// Indicates whether or not the page appear in the navigation.
        /// </summary>
        public bool Visible { get; set; }
        
        List<CMSPage> _childPages = null;
        /// <summary>
        /// A collections of sub or child pages for this page.
        /// </summary>
        public List<CMSPage> ChildPages
        {
            get
            {
                if (_childPages == null) _childPages = new List<CMSPage>();
                return _childPages;
            }
        }

        public List<CMSContent> _content;
        /// <summary>
        /// A collection of content used on this page and 
        /// keyed into the selected layout. If the content 
        /// does not have a key in the page's layout it will 
        /// be omitted from the page.
        /// </summary>
        public List<CMSContent> Content
        {
            get
            {
                if (_content == null) _content = new List<CMSContent>();
                return _content;
            }
        }
        
    }
}
